$(function(){
//查询所有药品类别
$.ajax({
    url:"/myspringboot/DrugCategoryController/fandAllDrugCategory",
    data:"",
    type:"post",
    dataType:"json",
    success:function(result){
        var result = result.data;
        var opts = "";
        for (var i = 0; i < result.length; i++) {
            var dcId = result[i].dcId;
            var dcName = result[i].dcName;
            var opt = '<option value="'+dcId+'">'+dcName+'</option>';
            opts += opt;
        }
        $(".b").append(opts);
    }
})

$.ajax({
    url:"/myspringboot/DrugInformationController/fandAll",
    data:"",
    type:"post",
    dataType:"json",
    success:function(result){
        var result = result.data;
        for (var i = 0; i < result.length; i++){
            var diId = result[i].diId;
            /*var daNumber = result[i].drugAtegory.daNumber;
            if(daNumber==null){
                daNumber="null"
            }*/
            var dat = result[i].drugAtegory;
            var daNumber = null;
            if(dat==null){
                daNumber="null";
            }else{
                daNumber=dat.daNumber;
            }
            var diName = result[i].diName;
            var diForm = result[i].diForm;
            var diSpecifications = result[i].diSpecifications;
            var diUnit = result[i].diUnit;
            var diCc = result[i].diCc;
            var diDaCategory = result[i].drugCategory.dcName;
            var diState = result[i].diState;
            if (diState==0){
                diState="正常"
            }else{
                diState='异常'
            }
            var $tr = '<tr>'+
                '<td>'+daNumber+'</td>'+
                '<td>'+diName+'</td>'+
                '<td>'+diForm+'</td>'+
                '<td>'+diSpecifications+'</td>'+
                '<td>'+diUnit+'</td>'+
                '<td>'+diCc+'</td>'+
                '<td>'+diDaCategory+'</td>'+
                '<td>'+diState+'</td>'+
                '<td><a data-toggle="modal" data-target="#Check" onclick="selectById('+diId+')">查看</a></td>\'+' +
                '<td><a data-toggle="modal" data-target="#Update" onclick="selectById('+diId+')">修改</a></td>\'+' +
                '<td><a onClick="return confirm(\'确认要删除？\')" href="/myspringboot/DrugInformationController/removeById?diId='+diId+'">删除</a></td>'+
                '</tr>'
            $(".a").append($tr);
        }
    }
})



})